<%@ page language="java" import="com.bifrii.bo.*,com.bifrii.dao.*,com.bifrii.transferObjects.*,java.util.*" %>
<% 
 	Community c= (Community)session.getAttribute("comunidad");
	c.setIdCommunity(CommunityManager.getInstance().getAllCommunities().get(0).getIdCommunity()+1);
 		CommunityManager.getInstance().newCommunity(c.getIdCommunity(),(Integer)session.getAttribute("session.user"),c.getName(),c.getIdCategory(),c.getDescription(),c.getAvatar());
 
 		List<User> users = (List<User>)session.getAttribute("usersCom");
        
    	String respuesta="FrontController?res=indexCommunity.jsp&id="+c.getIdCommunity();
    
    for(User u:users){
    	
    	if(request.getParameter("selectRole"+u.getIdUser())==null){
    		
    	}else{
    	CommunityManager.getInstance().addUser(c.getIdCommunity(),u.getIdUser(),Integer.parseInt(request.getParameter("selectRole"+u.getIdUser())));
    		respuesta="FrontController?res=indexCommunity.jsp&id="+c.getIdCommunity();
		}
    	}
    response.sendRedirect(respuesta);

%>
